﻿namespace com.stifel.GlobalDao
{
    using System;

    public partial class Timezone
    {
        #region Properties

        /// <summary>
        /// Gets the time difference between the current time zone's standard time and Coordinated Universal Time (UTC).
        /// </summary>
        public TimeSpan BaseUtcOffset
        {
            get
            {
                TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById( TimeZoneID );
                return tzi.BaseUtcOffset;
            }
        }

        #endregion Properties

        #region Methods

        /// <summary>
        /// Converts a Coordinated Universal Time (UTC) to the time in this time zone.
        /// </summary>
        /// <param name="dateTime">The Coordinated Universal Time (UTC).</param>
        /// <returns>A System.DateTime value that represents the date and time in this time zone.</returns>
        public DateTime ConvertTimeFromUtc( DateTime dateTime )
        {
            TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById( TimeZoneID );
            return TimeZoneInfo.ConvertTimeFromUtc( dateTime, tzi );
        }

        /// <summary>
        /// Converts the time in this time zone to Coordinated Universal Time (UTC).
        /// </summary>
        /// <param name="dateTime">The date and time in this time zone to convert.</param>
        /// <returns>A System.DateTime value that represents the Coordinated Universal time (UTC) that corresponds to the dateTime parameter.</returns>
        public DateTime ConvertTimeToUtc( DateTime dateTime )
        {
            TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById( TimeZoneID );
            return TimeZoneInfo.ConvertTimeToUtc( dateTime, tzi );
        }

        #endregion Methods
    }
}